<?php	$this->load->view('includes/header');	?>
<div class="container">
    <div class="row">
								<div class="col-md-9">
												<h1>Panel de Control <small>Listado de Peliculas</small></h1>
												<hr>
												<?php	if	(isset($error)	&&	$error):	?>
																<div class="alert alert-info alert-dismissable">
																				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
																				<?php
																				if	(isset($msg)	&&	$msg	!=	' ')	{
																								echo	$msg;
																				}
																				?>
																</div>

												<?php	endif	?>
												<table class="table table-bordered table-hover tablesorter">
                <thead>
																				<tr>
																								<th>Codigo <i class="fa fa-sort"></i></th>
																								<th>Nombre <i class="fa fa-sort"></i></th>
																								<th>Pais <i class="fa fa-sort"></i></th>
																								<th width="16px"><a data-toggle="modal" href="#myModal" ><i class="fa fa-plus-square-o"></i></a></th>
																				</tr>   
                </thead>
                <tbody>
																				<?php	foreach	($artistas	as	$value):	?>
																								<tr>
																												<td><?php	echo	$value['cod_asociacion'];	?></td>
																												<td><?php	echo	$value['nombre'];	?></td>
																												<td><?php	echo	$value['cod_pais'];	?></td>
																												<td>
																																<a id="mod" data-toggle="modal" data-cod="<?php	echo	$value['cod_asociacion'];	?>" data-nom="<?php	echo	$value['nombre'];	?>" data-pais="<?php	echo	$value['cod_pais'];	?>" href="#ModalModificar" title="Editar artista"><i class="fa fa-pencil"></i></a>
																																<a href="/artistas/eliminar/<?php	echo	$cod_pelicula	.	'/'	.	$value['cod_asociacion'];	?>/" title="Eliminar artista"><i class="fa fa-trash-o"></i></a>
																												</td>
																								</tr>
																				<?php	endforeach;	?>
                </tbody>
												</table>
								</div>
								<div id="div_oculto" style="display: none;"></div>
    </div>
</div>

<!-- Modal para el formulario añadir-->

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
								<div class="modal-content">
												<div class="modal-header">
																<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
																<h4 class="modal-title" id="myModalLabel">Agregar Artista</h4>
												</div>
												<form role="form" class="form_add" id="form_add_artista" action="/artistas/insertar/<?php	echo	$cod_pelicula;	?>" method="post">
																<div class="modal-body">
																				<div class="row">
																								<div class="form-group col-md-3">
																												<label>CODIGO</label>
																												<input class="form-control" name="cod_asociacion" > 
																								</div>
																								<div class="form-group col-md-9">
																												<label>Nombre</label>
																												<input type="text" class="form-control input_width10" name="nombre" > 
																								</div>
																								<div class="form-group col-md-9">
																												<label>PAIS</label>
																												<select class="form-control" name="cod_pais">
																																<?php	foreach	($cod_pais	as	$each):	?>
																																				<option value="<?php	echo	$each['cod_pais']	?>"><?php	echo	$each['nombre_pais']	?></option>
																																<?php	endforeach	?>
																												</select>
																								</div>
																								<div class="form-group col-md-9">
																												<label>Personaje</label>
																												<input type="text" class="form-control input_width10" name="personaje"> 
																								</div>

																								<div class="btn-group" data-toggle="buttons">
																												<label class="btn btn-primary">
																																<input type="radio" name="role" id="option1" value="0"> Director
																												</label>
																												<label class="btn btn-primary">
																																<input type="radio" name="role" id="option2" value="1"> Actor
																												</label>
																								</div>
																				</div>
																</div>
																<div class="modal-footer">
																				<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
																				<button type="submit" class="btn btn-primary">Añadir</button>
																</div>
												</form>
								</div>
    </div>
</div>				

<!-- Modal para el formulario modificar-->
<div class="modal fade" id="ModalModificar" tabindex="-1" role="dialog" aria-labelledby="ModalModificarLabel" aria-hidden="true">
    <div class="modal-dialog">
								<div class="modal-content">
												<div class="modal-header">
																<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
																<h4 class="modal-title" id="ModalModificarLabel">Modificar Artista</h4>
												</div>
												<form role="form" class="form_add" id="form_mod_artista" action="/artistas/modificar/<?php	echo	$cod_pelicula;	?>" method="post">
																<div class="modal-body">
																				<div class="row">
																								<div class="form-group col-md-3">
																												<label>CODIGO</label>
																												<input id="cod_form" class="form-control" name="cod_asociacion" value=""> 
																								</div>
																								<div class="form-group col-md-9">
																												<label>Nombre</label>
																												<input id="nom_form" type="text" class="form-control input_width10" name="nombre" value="" > 
																								</div>
																								<div class="form-group col-md-9">
																												<label>PAIS</label>
																												<select class="form-control" name="cod_pais">
																																<?php	foreach	($cod_pais	as	$each):	?>
																																				<option value="<?php	echo	$each['cod_pais']	?>" <?php if ($each['cod_pais'] == $cod_pais) {echo 'selected';} ?>><?php	echo	$each['nombre_pais']	?></option>
																																<?php	endforeach	?>
																												</select>
																								</div>
																								<div class="form-group col-md-9">
																												<label>Personaje</label>
																												<input type="text" class="form-control input_width10" name="personaje"> 
																								</div>

																								<div class="btn-group" data-toggle="buttons">
																												<label class="btn btn-primary">
																																<input type="radio" name="role" id="option1" value="0"> Director
																												</label>
																												<label class="btn btn-primary">
																																<input type="radio" name="role" id="option2" value="1"> Actor
																												</label>
																								</div>
																				</div>
																</div>
																<div class="modal-footer">
																				<button type="button" class="btn btn-default" data-dismiss="modal">Cancelar</button>
																				<button type="submit" class="btn btn-primary">Modificar</button>
																</div>
												</form>
								</div>
    </div>
</div>				
<script type="text/javascript">
				$(document).ready(function() {
 												$("#mod").click(function() {
																				$("#cod_form").val($(this).data("cod"));
																				$("#nom_form").val($(this).data("nom"));
																});
																});
				
</script>
<?php	$this->load->view('includes/footer');	?>